<?php
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

defined('IN_ADMIN') or die('Hacking Attempt!');

func::isLogin();
mysql::begin(0);

$sTable = 'inventory';

//get inventoryId
$iInventoryId = (isset($_GET['id']) && is_numeric($_GET['id'])) ? $_GET['id'] : 0;

if(!isset($_POST['updateInventoryButton'])){
        $sSql = 'SELECT * FROM '. $sTable .' WHERE inventoryId ='. $iInventoryId;
        $aResult = mysql::querySql($sSql);
}else{
     $aVals = array(
        'title' => isset($_POST['title']) ? func::cleanString($_POST['title']) : '',
        'price' => (isset($_POST['price']) && is_numeric(func::numberFormatInput($_POST['price']))) ? func::numberFormatInput($_POST['price']) : 0,
        'quantity' => (isset($_POST['quantity']) && is_numeric(func::numberFormatInput($_POST['quantity']))) ? func::numberFormatInput($_POST['quantity']) : 0,
        'date' => time()
    );

    $iIdUpdateInventory = mysql::updateSql($sTable, $aVals, 'inventoryId', $iInventoryId);
    if($iIdUpdateInventory)
        func::redirect(func::makeUrl('inventory', 'list'));
}
?>
